package com.xiaoxi.exam.controller;

import cn.xinzhili.xutils.core.http.Response;
import com.xiaoxi.exam.dao.PreOrderMapper;
import com.xiaoxi.exam.dao.UserMapper;
import com.xiaoxi.exam.model.PreOrder;
import com.xiaoxi.exam.model.PreOrderExample;
import com.xiaoxi.exam.model.User;
import com.xiaoxi.exam.model.UserExample;
import com.xiaoxi.exam.service.SyncService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sync")
public class SyncController {

  @Autowired
  private SyncService syncService;
  @Autowired
  private UserMapper userMapper;
  @Autowired
  private PreOrderMapper preOrderMapper;

//  @RequestMapping("/user/init")
//  public Response syncUser() {
//    UserExample example = new UserExample();
//    example.createCriteria().andDeletedAtIsNull();
//    List<User> users = userMapper.selectByExample(example);
////    users.forEach(u -> syncService.syncUser(u.getId()));
//    return Response.instanceSuccess();
//  }
//
//  @RequestMapping("/order/init")
//  public Response syncOrder() {
//    PreOrderExample example = new PreOrderExample();
//    example.createCriteria().andDeletedAtIsNull().andStatusEqualTo((short) 2);
//    List<PreOrder> orders = preOrderMapper.selectByExample(example);
////    orders.forEach(o -> syncService.syncOrder(o.getId()));
//    return Response.instanceSuccess();
//  }

}
